import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/auth/user/login',
    method: 'post',
    data
  })
}

export function register(params) {
  return request({
    url: '/auth/user/register',
    method: 'post',
    data: params
  })
}


export function getInfo(token) {
  return request({
    url: '/auth/user/getInfo',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/auth/user/logout',
    method: 'post'
  })
}

export function selectPage(params) {
  return request({
    url: '/auth/user/selectAllPage',
    method: 'post',
    data: params
  })
}

export function updateStatus(params) {
  return request({
    url: '/auth/user/updateStatus',
    method: 'post',
    data: params
  })
}


export function getInfoById(id) {
  return request({
    url: '/auth/user/getInfoById',
    method: 'get',
    params: { id }
  })
}

export function updateInfo(params) {
  return request({
    url: '/auth/user/updateInfo',
    method: 'post',
    data: params
  })
}

export function deleteById(id) {
  return request({
    url: '/auth/user/deleteById',
    method: 'get',
    params: { id }
  })
}

export function upload(uploadFile, bucket, objectName) {
  const formData = new FormData();
  formData.append('uploadFile', uploadFile); // 对应后端 MultipartFile 参数名
  formData.append('bucket', bucket);
  formData.append('objectName', objectName);

  return request({
    url: '/oss/file/uploadImage',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}


